﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skywave.DataStructure
{
    public class BinaryTreeNode
    {
        private object data;
        private BinaryTreeNode left, right, parent;

        #region Constructors
        public BinaryTreeNode() : this(null) { }
        public BinaryTreeNode(object data) : this(data, null, null) { }
        public BinaryTreeNode(object data, BinaryTreeNode left, BinaryTreeNode right)
        {
            this.data = data;
            this.Left = left;
            this.Right = right;
        }
        #endregion

        #region Public Properties
        public object Value
        {
            get
            {
                return data;
            }
            set
            {
                data = value;
            }
        }

        public BinaryTreeNode Left
        {
            get
            {
                return left;
            }
            set
            {
                left = value;
                if (left != null) left.Parent = this;
            }
        }

        public BinaryTreeNode Right
        {
            get
            {
                return right;
            }
            set
            {
                right = value;
                if (right != null) right.Parent = this;
            }
        }

        public BinaryTreeNode Parent
        {
            get
            {
                return parent;
            }
            set
            {
                parent = value;
            }
        }
        #endregion
    }
}
